var gLoginUsername = "${loginUsername}"; // 获得当前登录人员的userName
var curDept;

// @Bind @dtEmployee.onDataChange
!function(self, arg) {
	var ds = view.id('dsEmployee');
	var cur = ds.getData('#');

	if (cur) {
		if (arg.property == "uuid") {
			cur.set("BDFUser.username", cur.get("uuid"));
		}
	}
}

// @Bind @dtEmployee.beforeInsert
!function(self, arg) {
	var newEmployee = arg.entity;
	newEmployee.set("deptUid", curDept.get("uuid"));
	newEmployee.set("dept.deptName", curDept.get("deptName"));
}

// @Bind #saveEmployee.onSuccess
!function(self, arg, dsEmployee) {
	dsEmployee.flushAsync();

}

//@Bind #deptTree.onCurrentChange
!function(self, arg) {
	var curEntity = self.get("currentEntity");
	var dsEmployee = view.id("dsEmployee");

	if (curEntity.dataType.get("name") == "dtDept"){
		dsEmployee.set("parameter", {
			deptUid : curEntity.get("uuid")
		});
		
		curDept = curEntity;
	}
	
	dsEmployee.flush();
}

